<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="diagram">
  <link rel="stylesheet" href="./assets/common.css">
  <title>text layer</title>
  <style>
	#map { position:absolute; top:0; bottom:0; width:100%; }
  </style>
</head>

<body>
<div id="map"></div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>

const scene = new L7.Scene({
  id: 'map',
  mapStyle: 'dark', // 样式URL
  center: [ 120.19382669582967, 30.258134 ],
  pitch: 0,
  zoom: 1
});
window.scene = scene;
scene.on('loaded', () => {
  $.get('https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_geography_regions_points.geojson', data => {
   scene.PointLayer({
      zIndex: 3
    })
    .source(data)
    .shape('circle')
    .active(true)
    .size(4)
    .color('#fff')
    .style({
      stroke: '#999',
      strokeWidth: 1,
      opacity: 1.0
    })
    .render();

    layer = scene.TextLayer({
      zIndex: 4
    })
    .source(data)
    .shape('name', 'text')
    .filter(true)
    .active(true)
    .size('scalerank', [ 10, 20, 24 ])
    .color('scalerank', [ 'red', 'blue', 'black' ])
    .style({
      // fontFamily: 'Monaco, monospace', // 字体
      fontWeight: 400,
      textAnchor: 'center', // 文本相对锚点的位置 center|left|right|top|bottom|top-left
      textOffset: [ 0, 0 ], // 文本相对锚点的偏移量 [水平, 垂直]
      spacing: 2, // 字符间距
      padding: [ 4, 4 ], // 文本包围盒 padding [水平，垂直]，影响碰撞检测结果，避免相邻文本靠的太近
      stroke: 'white', // 描边颜色
      strokeWidth: 2, // 描边宽度
      opacity: 1.0
    })
    .render();
    setTimeout(()=>{
      layer.color('red').render();
      
    },2000)
  });
});

</script>
</body>
</html>

